package com.cy;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//通过yml的方式赋值
//通过properties的方式赋值
@RestController   //指定配置文件进行加载
@PropertySource("classpath:/properties/application.properties")
public class RedisController {
    @Value("${redis2.host}")
    private String redis2_host;
    @Value("${redis2.port}")
    private String redis2_port;
    @Value("${redis.host}")
    private String redis_host;
    @Value("${redis.port}")
    private String redis_port;
    @RequestMapping("/getMsg")
    public String getpro(){
        return "properties的取值方式"+redis2_host+":"+redis2_port;
        //依照 localhost:8090/getMsg来访问这个return
    }
    @RequestMapping("/getyml")
    public String getyml(){
        return "yml的取值方式"+redis_host+":"+redis_port;
        //依照 localhost:8090/getyml来访问这个return
    }

}
